package 笔试.广联达笔试.正式批第三题机器人愉悦;

import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

public class Main2
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int i1 = sc.nextInt();
        int i2 = sc.nextInt();
        double[] doubles = new double[i1];
        int[] ints = new int[i1];
        for (int i = 0; i < i1; i++)
        {
            //            String[] split = scanner.nextLine().trim().split(" ");
//            c[i]= Double.valueOf(split[0]).intValue();
//            v[i]= Integer.valueOf(split[1]);
            doubles[i] = sc.nextDouble();
            ints[i] = sc.nextInt();
        }
        int res = Helper(i2, i1, doubles, ints);
        System.out.println(res);
    }

    public static int Helper(int v, int n, double[] weight, int[] value)
    {
        int[] dp = new int[v + 1];
        for (int i = 1; i < n + 1; i++)
        {
            for (int j = v; j >= weight[i - 1]; j--)
            {
                dp[j] = Math.max(dp[j - (int) (Math.ceil(weight[i - 1]))] + value[i - 1], dp[j]);
            }
        }
        return dp[v];
    }

}
